package com.becca.cake.model.coupon;

import java.io.Serializable;
import java.util.Date;

import com.becca.cake.core.exception.ServiceException;
import com.becca.cake.util.StringUtil;

/**
 * 规则组别表
 * @copyright  尊星(上海)信息科技有限公司
 * @author hejinguo
 * @date 2016年6月30日 下午7:02:42
 */
public class RuleGroupModel implements Serializable {
    /**  */
    private static final long serialVersionUID = -5507189248924079839L;

    private Integer           id;

    /**规则组名称*/
    private String            ruleGroupName;

    /**是否可用(0:可用 1:不可用)*/
    private Byte              isEnable;

    /**创建时间*/
    private Date              createdDate;
    
    /**创建人*/
    private String            createdName;
    
    /**规则组名称不能为空*/
    public static final String RULE_GROUP_NAME_NULL = "规则组名称不能为空";
    /**是否可用不能为空*/
    public static final String IS_ENABLE_NULL = "是否可用不能为空";
    /**查询规则组时ID为空*/
    public static final String RULE_GROUP_ID_NULL  = "查询规则组时ID为空";
    /**查询规则组时ID为空*/
    public static final String RULE_GROUP_NULL  = "操作规则组对象为空";
    
    

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getRuleGroupName() {
        return ruleGroupName;
    }

    public void setRuleGroupName(String ruleGroupName) {
        this.ruleGroupName = ruleGroupName;
    }

    public Date getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Date createdDate) {
        this.createdDate = createdDate;
    }

    public String getCreatedName() {
        return createdName;
    }

    public void setCreatedName(String createdName) {
        this.createdName = createdName;
    }

    public Byte getIsEnable() {
        return isEnable;
    }

    public void setIsEnable(Byte isEnable) {
        this.isEnable = isEnable;
    }
    
    /**
     * 添加或修改规则组时数据校验
     * @param ruleGroupModel
     */
    public static void validAddOrUpdRuleGroup(RuleGroupModel ruleGroupModel){
        if(ruleGroupModel == null){
            throw new ServiceException(RuleGroupModel.RULE_GROUP_NULL);
        }
        if(StringUtil.isEmpty(ruleGroupModel.getRuleGroupName())){
            throw new ServiceException(RuleGroupModel.RULE_GROUP_NAME_NULL);
        }
        if(ruleGroupModel.getIsEnable() == null){
            throw new ServiceException(RuleGroupModel.IS_ENABLE_NULL);
        }
    }
    
    /**
     * 校验规则组ID是否为空
     * @param id
     */
    public static void validQueryRuleGroupById(Integer id){
        if(id == null){
            throw new ServiceException(RuleGroupModel.RULE_GROUP_ID_NULL);
        }
    }

}
